package com.chen.module.testproducerconsumer;

import android.os.MessageQueue;

/**
 * create by chen on 2020/3/25 16:52
 * Email:chenshaopeng90@hotmail.com
 */
public class ConsumerThread extends Thread{
    private CustomMessageQueue messageQueue;

    public ConsumerThread(CustomMessageQueue messageQueue , int seq) {
        //为线程起名字
        super("Consumer>>>>>" + seq);
        this.messageQueue = messageQueue;
    }

    @Override
    public void run() {
        while (true){
            try {
                CustomMessage message = messageQueue.take();
                System.out.println(Thread.currentThread().getName() + "   get MessageData：" + message.getData());
                Thread.sleep(100);
            }catch (Exception e){
                break;
            }

        }
    }
}